.TH std::move_iterator::base 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::move_iterator::base \- std::move_iterator::base

.SH Synopsis
   iterator_type base() const;                                    \fI(since C++11)\fP
                                                                  \fI(until C++17)\fP
   constexpr iterator_type base() const;                  \fB(1)\fP     \fI(since C++17)\fP
                                                                  \fI(until C++20)\fP
   constexpr const iterator_type& base() const& noexcept;         \fI(since C++20)\fP
   constexpr iterator_type base() &&;                         \fB(2)\fP \fI(since C++20)\fP

   Returns the underlying base iterator.

   1) Copy constructs the return value from the underlying iterator. \fI(until C++20)\fP
   1) Returns a reference to the underlying iterator.                \fI(since C++20)\fP

   2) Move constructs the return value from the underlying iterator.

.SH Parameters

   \fI(none)\fP

.SH Return value

   1) A copy of the underlying iterator.      \fI(until C++20)\fP
   1) A reference to the underlying iterator. \fI(since C++20)\fP

   2) An iterator move constructed from the underlying iterator.

.SH Exceptions

   May throw implementation-defined exceptions.

.SH Example


// Run this code

 #include <algorithm>
 #include <iostream>
 #include <iterator>
 #include <vector>

 int main()
 {
     std::vector<int> v{0, 1, 2, 3, 4};
     std::move_iterator<std::vector<int>::reverse_iterator>
         m1{v.rbegin()},
         m2{v.rend()};

     std::copy(m1.base(), m2.base(), std::ostream_iterator<int>(std::cout, " "));
     std::cout << '\\n';
 }

.SH Output:

 4 3 2 1 0

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

      DR    Applied to            Behavior as published              Correct behavior
   LWG 3391 C++20      the const version of base returns a copy of  returns a reference
                       the underlying iterator
   LWG 3593 C++20      the const version of base returns a          made noexcept
                       reference but might not be noexcept

.SH See also

   operator*
   operator->                   accesses the pointed-to element
   \fI(C++11)\fP                      \fI(public member function)\fP
   \fI(C++11)\fP(deprecated in C++20)
